<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >
<!--[if lt IE 9]>
　　　　<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
　　<![endif]-->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/sytle.css?v=0.2&d=2016-11-08">
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery/1.9.1/jquery.min.js?v=0.1"></script> 

<script type="text/javascript">
var InterValObj;
	var curCount=60;
$(function(){
	var isReg = false;
	var isSendMsg = true;
	
    $('#sendCode').click(function(){
    	$('#code').show();
    	var mobile = $("#mobile").val();
    });
   
    $('#sendCode').click(function() {
    	var is = true;
    	var mobile = $("#mobile").val();
    	if(mobile == '' || mobile.length < 10 || isNaN(mobile)) {
    		$("#tip").show();
  	   		$("#tipMsg").text("请输入手机号码");
 		  	is = false; 
 	   	}
    	
    	var mobile = $("#mobile").val();
    	
    	if(is) {
    		setRemainTime();
	   		$.ajax({
	               type: "GET",
	               url: "/members/getCode/" + mobile + "/2.json",
	               dataType: "json",
	               success: function(data){
	            	 
	            		   $("#tipMsg").text(data);
	            		   close();
                       
	               }
	           });
    	}
    });
    $("#btn_sub").click(function(){
 	    var is = true;
 		var mobile = $("#mobile").val();
 	   	if(mobile == '' || mobile.length < 10 || isNaN(mobile)) {
 	   	$("#tip").show();
	   		$("#tipMsg").text("请输入手机号码");
 		  	is = false; 
 		  	close();
 	   	}
 	    var smsCode =  $("#smsCode").val();
 	   
	    if(smsCode == '' || smsCode.length < 6) {
	    	$("#tip").show();
	   		$("#tipMsg").text("请输入短信验证码"); 
		  	is = false; 
		  	close();
	   	}
 	    var password =  $("#password").val();
 	    if(password == '' || password.length < 6) {
 	    	$("#tip").show();
	   		$("#tipMsg").text("请输入密码");  
		  	is = false; 
		  	close();
	   	}
 	   var repassword =  $("#repassword").val();
	    if(repassword == '' || repassword.length < 6) {
	    
	    	$("#tip").show();
	   		$("#tipMsg").text("请再次输入密码");  
		  	is = false; 
		  	if(repassword != password) {
		  	
		  		$("#tip").show();
		   		$("#tipMsg").text("两次密码输入不相同");  
		  		is = false;
		  		close();
		  	}
	   	}
	 
 	   	if(is) {
 	   		$("#restForm").submit();
 	   	}
 	});

 
 	 $('#smsCode').change(function() {
     	var mobile = $("#mobile").val();
     	var v = $('#smsCode').val();
     	if(v != "") {
     		$.ajax({
	               type: "GET",
	               url: "/members/vaidateMobile/" + mobile + "/" + v +".json",
	               dataType: "json",
	               success: function(data){
	                        if(data == 0) {
	                        	$("#tipMsg").text("验证码错误或者已经过期！", "警告对话框");
	                        } 
	               }
	           });
     	}
     })
      InterValObj = window.setInterval(setRemainTime, 1000); //启动计时器，1秒执行一次

});
//timer处理函数
	function setRemainTime() {
		 
     if (curCount == 0) {                
         window.clearInterval(InterValObj);//停止计时器
         $("#sc").html("<a href=\"javascript:void()\" class=\"yanzheng\" id=\"sendCode\" >获取验证码</a>");
         isSendMsg = true;
     }
     else {
         curCount--;
         isSendMsg = false;
         $("#sc").html("<span class=\"yanzheng\">" + curCount + "秒后可重新获取</span>");
     }
 }
</script>
<title>忘记密码</title>
</head>
<body>
<div class="hgj">
  <div class="page-all">
    <!--头部开始-->
    <header>
      <div class="navbar">
        <ul>
          <li class="l-back"><img src="${pageContext.request.contextPath}/images/left.png" alt="返回"/></li>
          <li class="n-word">忘记密码</li>
          <li class="n-intro"></li>
        </ul>
      </div>
    </header>
    <!---内容开始--->
    <div class="container">
    <form action="${pageContext.request.contextPath}/members/restPwd.html" method="post" id="restForm">
      <div class="former">
        <ul>
          <li>
            <input type="tel" pattern="[0-9]*" placeholder="请输入手机号码" id="mobile" name="wMMobile"  maxlength="11"  class="user-tel-s">
          </li>
          <li id="sc"><a href="javascript:void()" class="yanzheng" id="sendCode">获取验证码</a></li>
          <hr style=" width:100%; border:1px solid #D9D9D9; opacity:0.6; padding:0; margin:0" >
          <li>
            <input type="tel" pattern="[0-9]*" id="smsCode" placeholder="请输入验证码" name="smsCode" class="user-tel">
          </li>
          <li>
            <input type="password"   id="password" placeholder="请输入新密码"  name="wMPassword" class="user-tel">
          </li>
          <li>
            <input type="password"  id="repassword" placeholder="确认密码" class="user-tel">
          </li>
        </ul>
      </div>
     </form>
      <div class="login-btn"> <a href="javascript:void();" id="btn_sub">确定</a> </div>
      <!---提示弹窗(未输入验证码的弹出框，注册点击后弹出，2秒后自动消失)--->
      <div class="login-layer" style=" display:none;" id="tip"> <span id="tipMsg"></span> </div>
      
    </div>
  </div>
</div>
</body>
</html>
